package com;


import com.Mapper.UserMapper;
import com.pojo.user;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

public class mybatisDemo1 {
    public static void main(String[] args) throws Exception {
        test();
    }
    public static void test() throws Exception {
        String resource1 = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource1);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        //List<user> use = sqlSession.selectList("test.selectAll");

        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        List<user> users = mapper.selectAll();
        System.out.println(users);
        sqlSession.close();
    }
}
